﻿<html>
    
    <head>
        <title>
            Dialog Test - 吾乐吧软件站 - www.wuleba.com
        </title>
        <script>
            function show_alert() {
                window.alert("I am an alert box!");
            }

            function show_confirm() {
                var r = window.confirm("Press a button");
                var msg = r ? "You pressed OK!" : "You pressed Cancel!";
                window.document.getElementById('cm').innerText = msg;
            }

            function show_prompt() {
                var name = window.prompt("Please enter your name", "Harry Potter");
                if (name != null && name != "") window.document.getElementById('pm').innerText = "Hello " + name + "!";
            }

            window.onbeforeunload = function() {
                return 'This is an onbeforeunload message.';
            };

            function update_time() {
                window.document.getElementById('time').innerText = new Date().toLocaleString();
            }

            function setup() {
                update_time();
                window.setInterval(update_time, 1000);
            }

            function show_file_dialog(element, test) {
                var message = 'DialogTest.' + test;
                var target = window.document.getElementById(element);

                // Register for the callback from OnFileDialogDismissed in dialog_test.cpp.
                window.app.setMessageCallback(message,
                function (msg, paths) {
                    target.innerText = paths.join();
                    window.app.removeMessageCallback(message);
                });

                // This will result in a call to OnProcessMessageReceived in dialog_test.cpp.
                window.app.sendMessage(message);
            }

            window.addEventListener('load', setup, false);
        </script>
    </head>
    
    <body bgcolor="white">
        <form>
            Click a button to show the associated dialog type.
            <br/>
            <input type="button" onclick="show_alert();" value="Show Alert">
            <br/>
            <input type="button" onclick="show_confirm();" value="Show Confirm">
            <span id="cm">
            </span>
            <br/>
            <input type="button" onclick="show_prompt();" value="Show Prompt">
            <span id="pm">
            </span>
            <br/>
            input type="file":
            <input type="file" name="pic" accept="text/*,.js,.css,image/*">
            <br/>
            <input type="button" onclick="show_file_dialog('fo', 'FileOpen');" value="Show File Open">
            <span id="fo">
            </span>
            <br/>
            <input type="button" onclick="show_file_dialog('fom', 'FileOpenMultiple');"
            value="Show File Open Multiple">
            <span id="fom">
            </span>
            <br/>
            <input type="button" onclick="show_file_dialog('fs', 'FileSave');" value="Show File Save">
            <span id="fs">
            </span>
            <p id="time">
            </p>
        </form>
        <div style="display:none;">
            <script type="text/javascript">
                var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
                document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F73f8690e804607ec46bfd2f4375620cd' type='text/javascript'%3E%3C/script%3E"));
            </script>
            <script type="text/javascript">
                var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
                document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F2d23f9f93a74d085fbeb86b6d7607429' type='text/javascript'%3E%3C/script%3E"));
            </script>
        </div>
    </body>

</html>